#ifndef POPUP_MESSAGE_DIALOG_HPP
#define POPUP_MESSAGE_DIALOG_HPP

#include <vector>
#include <QtGui>
#include <PopupLibTypes.hpp>
#include <PopupGui.hpp>
#include <PopupUsersWidget.hpp>
#include <PopupNotificationFrame.hpp>
#include <PopupGui.hpp>
#include "ui_messagedialog.h"

class PopupUsersWidget;
class PopupMessageWidget;
class PopupThreadWidget;

struct PopupMessageDialog : public QDialog, private Ui_MessageDialog,
public PopupUsersObserver
{
  Q_OBJECT

public:
  PopupMessageDialog(QWidget *p_parent = 0);
  inline PopupMessageWidget *widget() { return m_mainWidget; }

  void userUpdated(const PopupUserExt *p_user,
                   unsigned short p_updateMask,
                   bool p_isNewUser);

  void localUserUpdated(unsigned short p_mask);

  void userStatisticsUpdated(const PopupUserExt *p_user,
                             unsigned short p_updateMask);

  void getThreadWidgets(std::vector<const PopupThreadWidget*>&) const;

public slots:
  void slot_applyNewSettings();
  void slot_onConnectionUpdate(bool p_connected);
  void slot_restoreThread(const PopupGui::PopupThreadSave & p_threadSave);

private slots:
  void slot_showSomeDialog();
  void slot_nicknameUpdated();
  void slot_browseAvatar();
  void slot_browseMode();
  void slot_onRequestUserChangeTimeout();

signals:
  void signal_showDialog(PopupGui::DialogID);

protected:
  void mouseMoveEvent(QMouseEvent *event);
  void mousePressEvent(QMouseEvent *event);
  void mouseReleaseEvent(QMouseEvent *event);
  void mouseDoubleClickEvent(QMouseEvent *event);

private:
  PopupMessageWidget *m_mainWidget;
  QPoint m_offsetInWidget;
  bool m_moving;
  PopupNotificationFrame m_notificationDlg;
};

#endif // POPUP_MESSAGE_DIALOG_HPP
